/**
 * Created by Dark on 2015/8/10.
 */

var HOME_URL = '/EachGo/index.php/Home';

$(document).ready( function(){
    /*
        登录模块ajax检测是否存在用户
     */
    $('#phone').blur(function(e){
        $.post(HOME_URL+'/User/isUser',{'phone': $('#phone').val()},function(data) {
            if(data.status == 0) {
                $("#no-user").html(data.info).prev().addClass("error");
            } else {
                $("#no-user").html('').prev().removeClass("error");
            }
            console.log(data.info);
        },"json")
    });

    /*
        登录模块检测密码是否匹配
     */
    $('#user-login').bind("click focus",function(){
        $.post(HOME_URL+'/User/login',
            {'LoginName':$('#phone').val(), 'userPassword':$('#password').val()},
            function(data) {
            if(data.status == 0) {
                $('#psd-error').html(data.info).prev().addClass('error');
            } else {
                $('#psd-error').html('').prev().removeClass('error');
                window.location.href= data.url;
            }
            console.log(data.info);
        },"json")
    });
});